﻿namespace KingerRobot.MexicoSailunWMS.SpiService
{
    internal class BCuringSpareImpl : ICuringSpare
    {
        public List<CuringSpareBeans> QueryCuringSpare()
        {
            var db = Db.Default;
            var query = db.WcsEquipCuringSpares.Select(f => new CuringSpareBeans
            {
                Id = f.Id,
                CuringCode = f.CuringCode,
                CuringName = f.CuringName,
                SpareNum = f.SpareNum,
                SpareCurrentNum = f.SpareCurrentNum,
                UseFlag = f.UseFlag != null && f.UseFlag == 1 ? "可用" : "不可用",
                CreateTime = f.CreateTime,
                UpdateTime = f.UpdateTime,
                UserName = f.UserName
            }).ToList();
            return query;
        }

        public int UpdateSpareById(UpdateSpareParam param)
        {
            var db = Db.Default;
            var result = db.WcsEquipCuringSpares.Where(f => f.Id == param.Id).Update( new POWcsEquipCuringSpare
            {
                SpareNum = param.SpareNum,
                UpdateTime = DateTime.Now,
                UserName = param.UserName
            });
            return result;
        }
    }
}
